﻿@using System.Globalization
@model AutoPartsSearch.Web.Areas.Administration.Models.LocalizeViews.IndexModel
@{
    ViewBag.Title = "Index";
    Layout = "~/Areas/Administration/Views/_Layout.cshtml";
    
}
@section menu
    {
        @Html.Partial("_contextMenu")
    }
<div class="griffin">
    <h2>@CultureInfo.CurrentUICulture.DisplayName</h2>
    @using (Html.BeginForm("CreateLanguage", "LocalizeViews"))
    {
        @Html.ValidationSummary(true)
        <div style="float: right">
            Изменить язык:
            @Html.DropDownList("changeLanguage", Model.CultureItems, "", CultureInfo.CurrentUICulture.Name)
        </div>
        <div>
            Создать язык (должен быть вида "sv-se")
            <input type="text" name="lang" />
            <input type="submit" value="Create" />
        </div>
    }
    <table>
        <tr>
            <th>
                Путь
            </th>
            <th style="width: 200px;">
                Текстовое поле
            </th>
            <th>
                Перевод
            </th>
            <th>
            </th>
        </tr>
        @foreach (var item in Model.Prompts)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.ViewPath)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.TextName)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.TranslatedText)
                </td>
                <td>
                    @Html.ActionLink("Edit", "Edit", new {id = item.TextKey})
                    @Html.ActionLink("Delete", "Delete", new {id = item.TextKey})
                    @if (item.ViewPath != "CommonPrompts")
                    {
                        @Html.ActionLink("Make common", "MakeCommon", new {id = item.TextKey}, new {title = "Use this phrase for texts with the same name that haven't got a translation."})
                    }
                </td>
            </tr>
        }
    </table>
    <script type="text/javascript">
        $(function() {
            $('#changeLanguage').change(function() {
                window.location = '@Url.Action("Index")?lang=' + $('#changeLanguage').val();
            });
        })
    </script>
</div>
